import 'dart:io';

import 'package:calendar_date_picker2/calendar_date_picker2.dart';
import 'package:file_picker/file_picker.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:get/get.dart';
import 'package:image_picker/image_picker.dart';
import 'package:smart_devices/bruno/src/components/actionsheet/brn_common_action_sheet.dart';
import 'package:smart_devices/bruno/src/components/button/brn_normal_button.dart';
import 'package:smart_devices/bruno/src/components/picker/time_picker/brn_date_time_formatter.dart';
import 'package:smart_devices/bruno/src/constants/brn_asset_constants.dart';
import 'package:smart_devices/bruno/src/theme/base/brn_text_style.dart';
import 'package:smart_devices/bruno/src/theme/configs/brn_action_sheet_config.dart';
import 'package:smart_devices/bruno/src/utils/brn_tools.dart';
import 'package:smart_devices/icons/src/antd_icons.dart';
import 'package:smart_devices/model/department.dart';
import 'package:smart_devices/model/user.dart';
import 'package:smart_devices/params/device.dart';
import 'package:smart_devices/routes/index.dart';
import 'package:smart_devices/ui/image_overlay.dart';
import 'package:smart_devices/utils/colors.dart';
import 'package:smart_devices/utils/styles.dart';
import 'package:smart_devices/utils/tools.dart';
import 'package:smart_devices/vo/device_supplier.dart';
import 'package:smart_devices/vo/purchase_order.dart';

import 'add_logic.dart';

class DeviceAddView extends GetView<DeviceAddLogic> {
  const DeviceAddView({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return GetBuilder(
      builder: (_) {
        return Scaffold(
            backgroundColor:
                ColorsUtils.parseColorFromHexString(ColorsUtils.colorF6f6),
            appBar: AppBar(
              leading: IconButton(
                icon: const Icon(
                  Icons.arrow_back_ios,
                  color: Colors.white,
                  size: 15,
                ),
                onPressed: Get.back,
              ),
              automaticallyImplyLeading: false,
              backgroundColor:
                  ColorsUtils.parseColorFromHexString(ColorsUtils.color0052),
              title: Text(
                '添加列表',
                style: StylesUtils.customTextStyle(
                    fontSize: 18, fontWeight: FontWeight.w700),
              ),
              centerTitle: true,
              systemOverlayStyle: SystemUiOverlayStyle.dark,
            ),
            body: SingleChildScrollView(
                padding: const EdgeInsets.only(left: 0, right: 0, bottom: 80),
                child: Obx(() => Column(
                      children: [
                        Container(
                          height: 40,
                          decoration: const BoxDecoration(color: Colors.white),
                          child: CustomPaint(
                              painter: _MyCustomPaintLine(),
                              child: Container(
                                margin: const EdgeInsets.only(left: 30),
                                alignment: Alignment.centerLeft,
                                child: Text(
                                  '设备信息',
                                  style: StylesUtils.customTextStyle(
                                      color: ColorsUtils.color6666),
                                ),
                              )),
                        ),
                        Container(
                          decoration: const BoxDecoration(color: Colors.white),
                          child: ListBody(
                            children: [
                              SizedBox(
                                height: 50,
                                child: Row(
                                  children: [
                                    Container(
                                      constraints: const BoxConstraints.expand(
                                          width: 100),
                                      alignment: Alignment.centerRight,
                                      child: Text(
                                        '设备编号',
                                        style: StylesUtils.customTextStyle(
                                            color: ColorsUtils.color3333),
                                      ),
                                    ),
                                    Expanded(
                                        child: Container(
                                            padding:
                                                const EdgeInsets.only(left: 10),
                                            alignment: Alignment.centerLeft,
                                            child: ObxValue(
                                                (form) => Text(
                                                      form.value.code ??
                                                          '系统自动生成',
                                                      style: StylesUtils
                                                          .customTextStyle(
                                                              color: form.value
                                                                          .code !=
                                                                      null
                                                                  ? ColorsUtils
                                                                      .color3333
                                                                  : ColorsUtils
                                                                      .colorCccc),
                                                    ),
                                                controller.form)))
                                  ],
                                ),
                              ),
                              SizedBox(
                                height: 50,
                                child: Row(
                                  children: [
                                    SizedBox(
                                      width: 100,
                                      child: Row(
                                        children: [
                                          Container(
                                            width: 40,
                                            alignment: Alignment.center,
                                            child: BrunoTools.getAssetSizeImage(
                                                BrnAsset.iconRequireRed, 8, 8,
                                                color: const Color(0xFFFA3F3F)),
                                          ),
                                          Expanded(
                                              child: Center(
                                            child: Text(
                                              '设备名称',
                                              style:
                                                  StylesUtils.customTextStyle(
                                                      color: ColorsUtils
                                                          .color3333),
                                            ),
                                          ))
                                        ],
                                      ),
                                    ),
                                    Expanded(
                                        child: Container(
                                      padding: const EdgeInsets.only(left: 10),
                                      alignment: Alignment.centerLeft,
                                      child: Obx(() => TextField(
                                            textDirection: TextDirection.ltr,
                                            controller: TextEditingController(
                                                text:
                                                    controller.form.value.name),
                                            cursorColor: ColorsUtils
                                                .parseColorFromHexString(
                                                    ColorsUtils.color1c24),
                                            style: StylesUtils.customTextStyle(
                                                fontSize: 16,
                                                color: ColorsUtils.color1c24),
                                            textAlign: TextAlign.left,
                                            textAlignVertical:
                                                TextAlignVertical.center,
                                            cursorWidth: 2,
                                            cursorRadius:
                                                const Radius.circular(2),
                                            decoration: InputDecoration(
                                                hintText: '请输入设备名称',
                                                hintStyle:
                                                    StylesUtils.customTextStyle(
                                                        color: ColorsUtils
                                                            .colorCccc,
                                                        fontSize: 15),
                                                isDense: true,
                                                isCollapsed: true,
                                                fillColor: Colors.white,
                                                border: InputBorder.none,
                                                focusColor: ColorsUtils
                                                    .parseColorFromHexString(
                                                        ColorsUtils.color1c24),
                                                contentPadding:
                                                    const EdgeInsets.symmetric(
                                                        vertical: 20),
                                                focusedBorder:
                                                    InputBorder.none),
                                            onChanged: (String text) {
                                              controller.form.value.name = text;
                                            },
                                          )),
                                    ))
                                  ],
                                ),
                              ),
                              SizedBox(
                                height: 50,
                                child: Row(
                                  children: [
                                    SizedBox(
                                        width: 100,
                                        child: Align(
                                          alignment: Alignment.centerRight,
                                          child: Text(
                                            '规格型号',
                                            style: StylesUtils.customTextStyle(
                                                color: ColorsUtils.color3333),
                                          ),
                                        )),
                                    Expanded(
                                        child: Container(
                                      padding: const EdgeInsets.only(left: 10),
                                      alignment: Alignment.centerLeft,
                                      child: Obx(() => TextField(
                                            textDirection: TextDirection.ltr,
                                            controller: TextEditingController(
                                                text: controller
                                                    .form.value.standards),
                                            cursorColor: ColorsUtils
                                                .parseColorFromHexString(
                                                    ColorsUtils.color1c24),
                                            style: StylesUtils.customTextStyle(
                                                fontSize: 16,
                                                color: ColorsUtils.color1c24),
                                            textAlign: TextAlign.left,
                                            textAlignVertical:
                                                TextAlignVertical.center,
                                            cursorWidth: 2,
                                            cursorRadius:
                                                const Radius.circular(2),
                                            decoration: InputDecoration(
                                                hintText: '请输入设备规格型号',
                                                hintStyle:
                                                    StylesUtils.customTextStyle(
                                                        color: ColorsUtils
                                                            .colorCccc,
                                                        fontSize: 15),
                                                isDense: true,
                                                isCollapsed: true,
                                                fillColor: Colors.white,
                                                border: InputBorder.none,
                                                focusColor: ColorsUtils
                                                    .parseColorFromHexString(
                                                        ColorsUtils.color1c24),
                                                contentPadding:
                                                    const EdgeInsets.symmetric(
                                                        vertical: 20),
                                                focusedBorder:
                                                    InputBorder.none),
                                            onChanged: (String text) {
                                              controller.form.value.standards =
                                                  text;
                                            },
                                          )),
                                    ))
                                  ],
                                ),
                              ),
                              SizedBox(
                                height: 50,
                                child: Row(
                                  children: [
                                    SizedBox(
                                      width: 100,
                                      child: Row(
                                        children: [
                                          Container(
                                            width: 40,
                                            alignment: Alignment.center,
                                            child: BrunoTools.getAssetSizeImage(
                                                BrnAsset.iconRequireRed, 8, 8,
                                                color: const Color(0xFFFA3F3F)),
                                          ),
                                          Expanded(
                                              child: Center(
                                            child: Text(
                                              '设备类型',
                                              style:
                                                  StylesUtils.customTextStyle(
                                                      color: ColorsUtils
                                                          .color3333),
                                            ),
                                          ))
                                        ],
                                      ),
                                    ),
                                    Expanded(
                                        child: Container(
                                      padding: const EdgeInsets.only(left: 10),
                                      alignment: Alignment.centerLeft,
                                      child: Obx(() => TextField(
                                            textDirection: TextDirection.ltr,
                                            readOnly: true,
                                            controller:
                                                controller.typeController.value,
                                            cursorColor: ColorsUtils
                                                .parseColorFromHexString(
                                                    ColorsUtils.color1c24),
                                            style: StylesUtils.customTextStyle(
                                                fontSize: 16,
                                                color: ColorsUtils.color1c24),
                                            textAlign: TextAlign.left,
                                            textAlignVertical:
                                                TextAlignVertical.center,
                                            cursorWidth: 2,
                                            cursorRadius:
                                                const Radius.circular(2),
                                            decoration: InputDecoration(
                                                hintText: '请选择设备类型',
                                                hintStyle:
                                                    StylesUtils.customTextStyle(
                                                        color: ColorsUtils
                                                            .colorCccc,
                                                        fontSize: 15),
                                                isDense: true,
                                                isCollapsed: true,
                                                fillColor: Colors.white,
                                                border: InputBorder.none,
                                                suffixIcon: Icon(
                                                  AntdIcons.right,
                                                  color: ColorsUtils
                                                      .parseColorFromHexString(
                                                          ColorsUtils
                                                              .color9999),
                                                  size: 15,
                                                ),
                                                focusColor: ColorsUtils
                                                    .parseColorFromHexString(
                                                        ColorsUtils.color1c24),
                                                contentPadding:
                                                    const EdgeInsets.only(
                                                        top: 10, bottom: 10),
                                                focusedBorder:
                                                    InputBorder.none),
                                            onTap: () {
                                              // showModalBottomSheet(
                                              //     context: context,
                                              //     backgroundColor: Colors.transparent,
                                              //     builder: (BuildContext context) {
                                              //       return BrnCommonActionSheet(
                                              //         actions: DeviceTypeEnum.values
                                              //             .where((element) => element != DeviceTypeEnum.all)
                                              //             .map((e) => BrnCommonActionSheetItem(e.label,
                                              //                 titleStyle: StylesUtils.customTextStyle(
                                              //                     fontSize: 16,
                                              //                     color: e.label ==
                                              //                             controller.form.value.type?.label
                                              //                         ? ColorsUtils.color0052
                                              //                         : ColorsUtils.color3333)))
                                              //             .toList(),
                                              //         cancelTitle: '取消',
                                              //         themeData: BrnActionSheetConfig(
                                              //             cancelStyle: BrnTextStyle(
                                              //               color: ColorsUtils.parseColorFromHexString(
                                              //                   ColorsUtils.colorE34d),
                                              //               fontWeight: FontWeight.normal,
                                              //               fontSize: 14,
                                              //             ),
                                              //             topRadius: 10),
                                              //         clickCallBack:
                                              //             (int index, BrnCommonActionSheetItem actionItem) {
                                              //           controller.form.value.type = DeviceTypeEnum.values
                                              //               .firstWhere((element) =>
                                              //                   element.label == actionItem.title);
                                              //           controller.typeController.value.text =
                                              //               actionItem.title;
                                              //         },
                                              //       );
                                              //     });
                                            },
                                          )),
                                    ))
                                  ],
                                ),
                              ),
                              SizedBox(
                                height: 50,
                                child: Row(
                                  children: [
                                    SizedBox(
                                      width: 100,
                                      child: Row(
                                        children: [
                                          Container(
                                            width: 40,
                                            alignment: Alignment.center,
                                            child: BrunoTools.getAssetSizeImage(
                                                BrnAsset.iconRequireRed, 8, 8,
                                                color: const Color(0xFFFA3F3F)),
                                          ),
                                          Expanded(
                                              child: Center(
                                            child: Text(
                                              '存放位置',
                                              style:
                                                  StylesUtils.customTextStyle(
                                                      color: ColorsUtils
                                                          .color3333),
                                            ),
                                          ))
                                        ],
                                      ),
                                    ),
                                    Expanded(
                                        child: Container(
                                      padding: const EdgeInsets.only(left: 10),
                                      alignment: Alignment.centerLeft,
                                      child: Obx(() => TextField(
                                          textDirection: TextDirection.ltr,
                                          readOnly: true,
                                          controller: controller
                                              .locationController.value,
                                          cursorColor:
                                              ColorsUtils.parseColorFromHexString(
                                                  ColorsUtils.color1c24),
                                          style: StylesUtils.customTextStyle(
                                              fontSize: 16,
                                              color: ColorsUtils.color1c24),
                                          textAlign: TextAlign.left,
                                          textAlignVertical:
                                              TextAlignVertical.center,
                                          cursorWidth: 2,
                                          cursorRadius:
                                              const Radius.circular(2),
                                          decoration: InputDecoration(
                                              hintText: '请选择设备类型',
                                              hintStyle:
                                                  StylesUtils.customTextStyle(
                                                      color:
                                                          ColorsUtils.colorCccc,
                                                      fontSize: 15),
                                              isDense: true,
                                              isCollapsed: true,
                                              fillColor: Colors.white,
                                              border: InputBorder.none,
                                              suffixIcon: Icon(
                                                AntdIcons.right,
                                                color: ColorsUtils
                                                    .parseColorFromHexString(
                                                        ColorsUtils.color9999),
                                                size: 15,
                                              ),
                                              focusColor: ColorsUtils
                                                  .parseColorFromHexString(
                                                      ColorsUtils.color1c24),
                                              contentPadding:
                                                  const EdgeInsets.only(
                                                      top: 10, bottom: 10),
                                              focusedBorder: InputBorder.none),
                                          onTap: () {
                                            Future<dynamic>? future =
                                                Get.toNamed(
                                                    Routes.deviceLocation);
                                            if (future != null) {
                                              future.then((result) {
                                                controller.form.value.location =
                                                    result as String;
                                                controller.locationController
                                                        .value.text =
                                                    controller
                                                        .form.value.location!;
                                              });
                                            }
                                          })),
                                    ))
                                  ],
                                ),
                              ),
                              SizedBox(
                                height: 50,
                                child: Row(
                                  children: [
                                    Container(
                                      width: 100,
                                      alignment: Alignment.centerRight,
                                      child: Text('备       注',
                                          textAlign: TextAlign.left,
                                          textDirection: TextDirection.rtl,
                                          style: TextStyle(
                                            letterSpacing: 0,
                                            fontSize: 14,
                                            color: ColorsUtils
                                                .parseColorFromHexString(
                                                    ColorsUtils.color3333),
                                            fontWeight: FontWeight.normal,
                                            fontFamily: 'Regular',
                                          )),
                                    )
                                  ],
                                ),
                              ),
                              Container(
                                padding: const EdgeInsets.only(left: 40),
                                child: Obx(() => TextField(
                                      textDirection: TextDirection.ltr,
                                      controller: TextEditingController(
                                          text: controller.form.value.remark),
                                      cursorColor:
                                          ColorsUtils.parseColorFromHexString(
                                              ColorsUtils.color1c24),
                                      style: StylesUtils.customTextStyle(
                                          fontSize: 14,
                                          color: ColorsUtils.color1c24),
                                      textAlign: TextAlign.left,
                                      textAlignVertical:
                                          TextAlignVertical.center,
                                      cursorWidth: 2,
                                      maxLines: 6,
                                      cursorRadius: const Radius.circular(2),
                                      decoration: InputDecoration(
                                          hintText: '请输入备注',
                                          hintStyle:
                                              StylesUtils.customTextStyle(
                                                  color: ColorsUtils.colorCccc,
                                                  fontSize: 15),
                                          isDense: true,
                                          isCollapsed: true,
                                          fillColor: Colors.white,
                                          border: InputBorder.none,
                                          focusColor: ColorsUtils
                                              .parseColorFromHexString(
                                                  ColorsUtils.color1c24),
                                          contentPadding:
                                              const EdgeInsets.symmetric(
                                                  vertical: 20),
                                          focusedBorder: InputBorder.none),
                                      onChanged: (String text) {
                                        controller.form.value.remark = text;
                                      },
                                    )),
                              )
                            ],
                          ),
                        ),
                        Container(
                          height: 40,
                          margin: const EdgeInsets.only(top: 15),
                          decoration: const BoxDecoration(color: Colors.white),
                          child: CustomPaint(
                              painter: _MyCustomPaintLine(),
                              child: Container(
                                margin: const EdgeInsets.only(left: 30),
                                alignment: Alignment.centerLeft,
                                child: Text(
                                  '使用情况',
                                  style: StylesUtils.customTextStyle(
                                      color: ColorsUtils.color6666),
                                ),
                              )),
                        ),
                        Container(
                          decoration: const BoxDecoration(color: Colors.white),
                          child: ListBody(
                            children: [
                              SizedBox(
                                height: 50,
                                child: Row(
                                  children: [
                                    SizedBox(
                                      width: 100,
                                      child: Row(
                                        children: [
                                          Container(
                                            width: 40,
                                            alignment: Alignment.center,
                                            child: BrunoTools.getAssetSizeImage(
                                                BrnAsset.iconRequireRed, 8, 8,
                                                color: const Color(0xFFFA3F3F)),
                                          ),
                                          Expanded(
                                              child: Center(
                                            child: Text(
                                              '设备状态',
                                              style:
                                                  StylesUtils.customTextStyle(
                                                      color: ColorsUtils
                                                          .color3333),
                                            ),
                                          ))
                                        ],
                                      ),
                                    ),
                                    Expanded(
                                        child: Container(
                                      padding: const EdgeInsets.only(left: 10),
                                      alignment: Alignment.centerLeft,
                                      child: Obx(() => TextField(
                                            textDirection: TextDirection.ltr,
                                            readOnly: true,
                                            controller: controller
                                                .statusController.value,
                                            cursorColor: ColorsUtils
                                                .parseColorFromHexString(
                                                    ColorsUtils.color1c24),
                                            style: StylesUtils.customTextStyle(
                                                fontSize: 16,
                                                color: ColorsUtils.color1c24),
                                            textAlign: TextAlign.left,
                                            textAlignVertical:
                                                TextAlignVertical.center,
                                            cursorWidth: 2,
                                            cursorRadius:
                                                const Radius.circular(2),
                                            decoration: InputDecoration(
                                                hintText: '请选择设备类型',
                                                hintStyle:
                                                    StylesUtils.customTextStyle(
                                                        color: ColorsUtils
                                                            .colorCccc,
                                                        fontSize: 15),
                                                isDense: true,
                                                isCollapsed: true,
                                                fillColor: Colors.white,
                                                border: InputBorder.none,
                                                suffixIcon: Icon(
                                                  AntdIcons.right,
                                                  color: ColorsUtils
                                                      .parseColorFromHexString(
                                                          ColorsUtils
                                                              .color9999),
                                                  size: 15,
                                                ),
                                                focusColor: ColorsUtils
                                                    .parseColorFromHexString(
                                                        ColorsUtils.color1c24),
                                                contentPadding:
                                                    const EdgeInsets.only(
                                                        top: 10, bottom: 10),
                                                focusedBorder:
                                                    InputBorder.none),
                                            onTap: () {
                                              showModalBottomSheet(
                                                  context: context,
                                                  backgroundColor:
                                                      Colors.transparent,
                                                  builder:
                                                      (BuildContext context) {
                                                    return BrnCommonActionSheet(
                                                      actions: DeviceStatusEnum
                                                          .values
                                                          .where((element) =>
                                                              element !=
                                                              DeviceStatusEnum
                                                                  .all)
                                                          .map((e) => BrnCommonActionSheetItem(
                                                              e.label,
                                                              titleStyle: StylesUtils.customTextStyle(
                                                                  fontSize: 16,
                                                                  color: e.label ==
                                                                          controller
                                                                              .form
                                                                              .value
                                                                              .type
                                                                              ?.label
                                                                      ? ColorsUtils
                                                                          .color0052
                                                                      : ColorsUtils
                                                                          .color3333)))
                                                          .toList(),
                                                      cancelTitle: '取消',
                                                      themeData:
                                                          BrnActionSheetConfig(
                                                              cancelStyle:
                                                                  BrnTextStyle(
                                                                color: ColorsUtils
                                                                    .parseColorFromHexString(
                                                                        ColorsUtils
                                                                            .colorE34d),
                                                                fontWeight:
                                                                    FontWeight
                                                                        .normal,
                                                                fontSize: 14,
                                                              ),
                                                              topRadius: 10),
                                                      clickCallBack: (int index,
                                                          BrnCommonActionSheetItem
                                                              actionItem) {
                                                        controller.form.value
                                                                .status =
                                                            DeviceStatusEnum
                                                                .values
                                                                .firstWhere((element) =>
                                                                    element
                                                                        .label ==
                                                                    actionItem
                                                                        .title);
                                                        controller
                                                                .statusController
                                                                .value
                                                                .text =
                                                            actionItem.title;
                                                      },
                                                    );
                                                  });
                                            },
                                          )),
                                    ))
                                  ],
                                ),
                              ),
                              SizedBox(
                                height: 50,
                                child: Row(
                                  children: [
                                    SizedBox(
                                      width: 100,
                                      child: Row(
                                        children: [
                                          Container(
                                            width: 40,
                                          ),
                                          Expanded(
                                              child: Center(
                                            child: Text(
                                              '使用部门',
                                              style:
                                                  StylesUtils.customTextStyle(
                                                      color: ColorsUtils
                                                          .color3333),
                                            ),
                                          ))
                                        ],
                                      ),
                                    ),
                                    Expanded(
                                        child: Container(
                                      padding: const EdgeInsets.only(left: 10),
                                      alignment: Alignment.centerLeft,
                                      child: Obx(() => TextField(
                                          textDirection: TextDirection.ltr,
                                          readOnly: true,
                                          controller: controller
                                              .departmentController.value,
                                          cursorColor:
                                              ColorsUtils.parseColorFromHexString(
                                                  ColorsUtils.color1c24),
                                          style: StylesUtils.customTextStyle(
                                              fontSize: 16,
                                              color: ColorsUtils.color1c24),
                                          textAlign: TextAlign.left,
                                          textAlignVertical:
                                              TextAlignVertical.center,
                                          cursorWidth: 2,
                                          cursorRadius:
                                              const Radius.circular(2),
                                          decoration: InputDecoration(
                                              hintText: '请选择当使用部门',
                                              hintStyle:
                                                  StylesUtils.customTextStyle(
                                                      color:
                                                          ColorsUtils.colorCccc,
                                                      fontSize: 15),
                                              isDense: true,
                                              isCollapsed: true,
                                              fillColor: Colors.white,
                                              border: InputBorder.none,
                                              suffixIcon: Icon(
                                                AntdIcons.right,
                                                color: ColorsUtils
                                                    .parseColorFromHexString(
                                                        ColorsUtils.color9999),
                                                size: 15,
                                              ),
                                              focusColor: ColorsUtils
                                                  .parseColorFromHexString(
                                                      ColorsUtils.color1c24),
                                              contentPadding:
                                                  const EdgeInsets.only(
                                                      top: 10, bottom: 10),
                                              focusedBorder: InputBorder.none),
                                          onTap: () {
                                            Future<dynamic>? future =
                                                Get.toNamed(Routes.deptSelect);
                                            if (future != null) {
                                              future.then((result) {
                                                if (result != null) {
                                                  controller.form.value
                                                          .department =
                                                      result['dept']
                                                          as DepartmentModel;
                                                  controller
                                                          .departmentController
                                                          .value
                                                          .text =
                                                      controller.form.value
                                                          .department!.name;
                                                }
                                              });
                                            }
                                          })),
                                    ))
                                  ],
                                ),
                              ),
                              SizedBox(
                                height: 50,
                                child: Row(
                                  children: [
                                    SizedBox(
                                      width: 100,
                                      child: Row(
                                        children: [
                                          Container(
                                            width: 40,
                                          ),
                                          Expanded(
                                              child: Center(
                                            child: Text(
                                              '负责人',
                                              style:
                                                  StylesUtils.customTextStyle(
                                                      color: ColorsUtils
                                                          .color3333),
                                            ),
                                          ))
                                        ],
                                      ),
                                    ),
                                    Expanded(
                                        child: Container(
                                      padding: const EdgeInsets.only(left: 10),
                                      alignment: Alignment.centerLeft,
                                      child: Obx(() => TextField(
                                          textDirection: TextDirection.ltr,
                                          readOnly: true,
                                          controller:
                                              controller.userController.value,
                                          cursorColor: ColorsUtils
                                              .parseColorFromHexString(
                                                  ColorsUtils.color1c24),
                                          style: StylesUtils.customTextStyle(
                                              fontSize: 16,
                                              color: ColorsUtils.color1c24),
                                          textAlign: TextAlign.left,
                                          textAlignVertical:
                                              TextAlignVertical.center,
                                          cursorWidth: 2,
                                          cursorRadius:
                                              const Radius.circular(2),
                                          decoration: InputDecoration(
                                              hintText: '请选择负责人',
                                              hintStyle:
                                                  StylesUtils.customTextStyle(
                                                      color:
                                                          ColorsUtils.colorCccc,
                                                      fontSize: 15),
                                              isDense: true,
                                              isCollapsed: true,
                                              fillColor: Colors.white,
                                              border: InputBorder.none,
                                              suffixIcon: Icon(
                                                AntdIcons.right,
                                                color: ColorsUtils
                                                    .parseColorFromHexString(
                                                        ColorsUtils.color9999),
                                                size: 15,
                                              ),
                                              focusColor: ColorsUtils
                                                  .parseColorFromHexString(
                                                      ColorsUtils.color1c24),
                                              contentPadding:
                                                  const EdgeInsets.only(
                                                      top: 10, bottom: 10),
                                              focusedBorder: InputBorder.none),
                                          onTap: () {
                                            Future<dynamic>? future =
                                                Get.toNamed(Routes.deptSelect);
                                            if (future != null) {
                                              future.then((result) {
                                                if (result) {
                                                  controller.form.value.user =
                                                      result['user']
                                                          as UserModel;
                                                  controller.userController
                                                          .value.text =
                                                      controller.form.value
                                                          .user!.name;
                                                }
                                              });
                                            }
                                          })),
                                    ))
                                  ],
                                ),
                              ),
                              SizedBox(
                                height: 50,
                                child: Row(
                                  children: [
                                    SizedBox(
                                        width: 100,
                                        child: Align(
                                          alignment: Alignment.centerRight,
                                          child: Text(
                                            '联系方式',
                                            style: StylesUtils.customTextStyle(
                                                color: ColorsUtils.color3333),
                                          ),
                                        )),
                                    Expanded(
                                        child: Container(
                                      padding: const EdgeInsets.only(left: 10),
                                      alignment: Alignment.centerLeft,
                                      child: Obx(() => TextField(
                                            textDirection: TextDirection.ltr,
                                            keyboardType: TextInputType.phone,
                                            controller: TextEditingController(
                                                text: controller
                                                    .form.value.mobile),
                                            cursorColor: ColorsUtils
                                                .parseColorFromHexString(
                                                    ColorsUtils.color1c24),
                                            style: StylesUtils.customTextStyle(
                                                fontSize: 16,
                                                color: ColorsUtils.color1c24),
                                            textAlign: TextAlign.left,
                                            textAlignVertical:
                                                TextAlignVertical.center,
                                            cursorWidth: 2,
                                            cursorRadius:
                                                const Radius.circular(2),
                                            decoration: InputDecoration(
                                                hintText: '请输入联系方式',
                                                hintStyle:
                                                    StylesUtils.customTextStyle(
                                                        color: ColorsUtils
                                                            .colorCccc,
                                                        fontSize: 15),
                                                isDense: true,
                                                isCollapsed: true,
                                                fillColor: Colors.white,
                                                border: InputBorder.none,
                                                focusColor: ColorsUtils
                                                    .parseColorFromHexString(
                                                        ColorsUtils.color1c24),
                                                contentPadding:
                                                    const EdgeInsets.symmetric(
                                                        vertical: 20),
                                                focusedBorder:
                                                    InputBorder.none),
                                            onChanged: (String text) {
                                              controller.form.value.mobile =
                                                  text;
                                            },
                                          )),
                                    ))
                                  ],
                                ),
                              ),
                              SizedBox(
                                height: 50,
                                child: Row(
                                  children: [
                                    SizedBox(
                                      width: 100,
                                      child: Row(
                                        children: [
                                          Container(
                                            width: 40,
                                          ),
                                          Expanded(
                                              child: Center(
                                            child: Text(
                                              '启用日期',
                                              style:
                                                  StylesUtils.customTextStyle(
                                                      color: ColorsUtils
                                                          .color3333),
                                            ),
                                          ))
                                        ],
                                      ),
                                    ),
                                    Expanded(
                                        child: Container(
                                      padding: const EdgeInsets.only(left: 10),
                                      alignment: Alignment.centerLeft,
                                      child: Obx(() => TextField(
                                          textDirection: TextDirection.ltr,
                                          readOnly: true,
                                          controller: controller
                                              .startDateController.value,
                                          cursorColor:
                                              ColorsUtils.parseColorFromHexString(
                                                  ColorsUtils.color1c24),
                                          style: StylesUtils.customTextStyle(
                                              fontSize: 16,
                                              color: ColorsUtils.color1c24),
                                          textAlign: TextAlign.left,
                                          textAlignVertical:
                                              TextAlignVertical.center,
                                          cursorWidth: 2,
                                          cursorRadius:
                                              const Radius.circular(2),
                                          decoration: InputDecoration(
                                              hintText: '请选择启用日期',
                                              hintStyle:
                                                  StylesUtils.customTextStyle(
                                                      color:
                                                          ColorsUtils.colorCccc,
                                                      fontSize: 15),
                                              isDense: true,
                                              isCollapsed: true,
                                              fillColor: Colors.white,
                                              border: InputBorder.none,
                                              suffixIcon: Icon(
                                                AntdIcons.right,
                                                color: ColorsUtils
                                                    .parseColorFromHexString(
                                                        ColorsUtils.color9999),
                                                size: 15,
                                              ),
                                              focusColor: ColorsUtils
                                                  .parseColorFromHexString(
                                                      ColorsUtils.color1c24),
                                              contentPadding:
                                                  const EdgeInsets.only(
                                                      top: 10, bottom: 10),
                                              focusedBorder: InputBorder.none),
                                          onTap: () async {
                                            List<DateTime?>? results =
                                                await showCalendarDatePicker2Dialog(
                                              context: context,
                                              config:
                                                  CalendarDatePicker2WithActionButtonsConfig(
                                                calendarType:
                                                    CalendarDatePicker2Type
                                                        .single,
                                                calendarViewMode:
                                                    DatePickerMode.day,
                                                weekdayLabels: [
                                                  '日',
                                                  '一',
                                                  '二',
                                                  '三',
                                                  '四',
                                                  '五',
                                                  '六',
                                                ],
                                              ),
                                              dialogSize: const Size(325, 400),
                                              borderRadius:
                                                  BorderRadius.circular(15),
                                            );
                                            if (results != null &&
                                                results.isNotEmpty) {
                                              DateTime? d = results[0];
                                              if (d != null) {
                                                String startDate =
                                                    DateTimeFormatter
                                                        .formatDate(
                                                            d, 'yyyy-MM-dd');
                                                controller.form.value
                                                    .startDate = startDate;
                                                controller.startDateController
                                                    .value.text = startDate;
                                              }
                                            }
                                          })),
                                    ))
                                  ],
                                ),
                              ),
                              SizedBox(
                                height: 50,
                                child: Row(
                                  children: [
                                    SizedBox(
                                        width: 100,
                                        child: Align(
                                          alignment: Alignment.centerRight,
                                          child: Text(
                                            '总功率',
                                            style: StylesUtils.customTextStyle(
                                                color: ColorsUtils.color3333),
                                          ),
                                        )),
                                    Expanded(
                                        child: Container(
                                      padding: const EdgeInsets.only(left: 10),
                                      alignment: Alignment.centerLeft,
                                      child: Obx(() => TextField(
                                            textDirection: TextDirection.ltr,
                                            keyboardType: TextInputType.number,
                                            controller: TextEditingController(
                                                text: controller
                                                    .form.value.power),
                                            cursorColor: ColorsUtils
                                                .parseColorFromHexString(
                                                    ColorsUtils.color1c24),
                                            style: StylesUtils.customTextStyle(
                                                fontSize: 16,
                                                color: ColorsUtils.color1c24),
                                            textAlign: TextAlign.left,
                                            textAlignVertical:
                                                TextAlignVertical.center,
                                            cursorWidth: 2,
                                            cursorRadius:
                                                const Radius.circular(2),
                                            decoration: InputDecoration(
                                                hintText: '请输入总功率',
                                                hintStyle:
                                                    StylesUtils.customTextStyle(
                                                        color: ColorsUtils
                                                            .colorCccc,
                                                        fontSize: 15),
                                                isDense: true,
                                                isCollapsed: true,
                                                fillColor: Colors.white,
                                                border: InputBorder.none,
                                                focusColor: ColorsUtils
                                                    .parseColorFromHexString(
                                                        ColorsUtils.color1c24),
                                                contentPadding:
                                                    const EdgeInsets.symmetric(
                                                        vertical: 20),
                                                focusedBorder:
                                                    InputBorder.none),
                                            onChanged: (String text) {
                                              controller.form.value.power =
                                                  text;
                                            },
                                          )),
                                    ))
                                  ],
                                ),
                              ),
                            ],
                          ),
                        ),
                        Container(
                          height: 40,
                          margin: const EdgeInsets.only(top: 15),
                          decoration: const BoxDecoration(color: Colors.white),
                          child: CustomPaint(
                              painter: _MyCustomPaintLine(),
                              child: Container(
                                margin: const EdgeInsets.only(left: 30),
                                alignment: Alignment.centerLeft,
                                child: Text(
                                  '购置信息',
                                  style: StylesUtils.customTextStyle(
                                      color: ColorsUtils.color6666),
                                ),
                              )),
                        ),
                        Container(
                          decoration: const BoxDecoration(color: Colors.white),
                          child: ListBody(
                            children: [
                              SizedBox(
                                height: 50,
                                child: Row(
                                  children: [
                                    SizedBox(
                                      width: 100,
                                      child: Row(
                                        children: [
                                          Container(
                                            width: 40,
                                          ),
                                          Expanded(
                                              child: Center(
                                            child: Text(
                                              '采购订单',
                                              style:
                                                  StylesUtils.customTextStyle(
                                                      color: ColorsUtils
                                                          .color3333),
                                            ),
                                          ))
                                        ],
                                      ),
                                    ),
                                    Expanded(
                                        child: Container(
                                      padding: const EdgeInsets.only(left: 10),
                                      alignment: Alignment.centerLeft,
                                      child: Obx(() => TextField(
                                          textDirection: TextDirection.ltr,
                                          readOnly: true,
                                          controller:
                                              controller.orderController.value,
                                          cursorColor: ColorsUtils
                                              .parseColorFromHexString(
                                                  ColorsUtils.color1c24),
                                          style: StylesUtils.customTextStyle(
                                              fontSize: 16,
                                              color: ColorsUtils.color1c24),
                                          textAlign: TextAlign.left,
                                          textAlignVertical:
                                              TextAlignVertical.center,
                                          cursorWidth: 2,
                                          cursorRadius:
                                              const Radius.circular(2),
                                          decoration: InputDecoration(
                                              hintText: '请选择采购订单',
                                              hintStyle:
                                                  StylesUtils.customTextStyle(
                                                      color:
                                                          ColorsUtils.colorCccc,
                                                      fontSize: 15),
                                              isDense: true,
                                              isCollapsed: true,
                                              fillColor: Colors.white,
                                              border: InputBorder.none,
                                              suffixIcon: Icon(
                                                AntdIcons.right,
                                                color: ColorsUtils
                                                    .parseColorFromHexString(
                                                        ColorsUtils.color9999),
                                                size: 15,
                                              ),
                                              focusColor: ColorsUtils
                                                  .parseColorFromHexString(
                                                      ColorsUtils.color1c24),
                                              contentPadding:
                                                  const EdgeInsets.only(
                                                      top: 10, bottom: 10),
                                              focusedBorder: InputBorder.none),
                                          onTap: () {
                                            Future<dynamic>? future =
                                                Get.toNamed(
                                                    Routes.purchaseOrder);
                                            if (future != null) {
                                              future.then((result) {
                                                if (result != null) {
                                                  PurchaseOrderVo order =
                                                      result as PurchaseOrderVo;
                                                  controller.form.value.oderNo =
                                                      order.orderNo;
                                                  controller.orderController
                                                          .value.text =
                                                      controller
                                                          .form.value.oderNo!;
                                                }
                                              });
                                            }
                                          })),
                                    ))
                                  ],
                                ),
                              ),
                              SizedBox(
                                height: 50,
                                child: Row(
                                  children: [
                                    SizedBox(
                                      width: 100,
                                      child: Row(
                                        children: [
                                          Container(
                                            width: 40,
                                          ),
                                          Expanded(
                                              child: Center(
                                            child: Text(
                                              '供应商',
                                              style:
                                                  StylesUtils.customTextStyle(
                                                      color: ColorsUtils
                                                          .color3333),
                                            ),
                                          ))
                                        ],
                                      ),
                                    ),
                                    Expanded(
                                        child: Container(
                                      padding: const EdgeInsets.only(left: 10),
                                      alignment: Alignment.centerLeft,
                                      child: Obx(() => TextField(
                                          textDirection: TextDirection.ltr,
                                          readOnly: true,
                                          controller: controller
                                              .supplierController.value,
                                          cursorColor:
                                              ColorsUtils.parseColorFromHexString(
                                                  ColorsUtils.color1c24),
                                          style: StylesUtils.customTextStyle(
                                              fontSize: 16,
                                              color: ColorsUtils.color1c24),
                                          textAlign: TextAlign.left,
                                          textAlignVertical:
                                              TextAlignVertical.center,
                                          cursorWidth: 2,
                                          cursorRadius:
                                              const Radius.circular(2),
                                          decoration: InputDecoration(
                                              hintText: '请选择供应商',
                                              hintStyle:
                                                  StylesUtils.customTextStyle(
                                                      color:
                                                          ColorsUtils.colorCccc,
                                                      fontSize: 15),
                                              isDense: true,
                                              isCollapsed: true,
                                              fillColor: Colors.white,
                                              border: InputBorder.none,
                                              suffixIcon: Icon(
                                                AntdIcons.right,
                                                color: ColorsUtils
                                                    .parseColorFromHexString(
                                                        ColorsUtils.color9999),
                                                size: 15,
                                              ),
                                              focusColor: ColorsUtils
                                                  .parseColorFromHexString(
                                                      ColorsUtils.color1c24),
                                              contentPadding:
                                                  const EdgeInsets.only(
                                                      top: 10, bottom: 10),
                                              focusedBorder: InputBorder.none),
                                          onTap: () {
                                            Future<dynamic>? future =
                                                Get.toNamed(
                                                    Routes.deviceSupplier);
                                            if (future != null) {
                                              future.then((result) {
                                                if (result != null) {
                                                  DeviceSupplierVo supplier =
                                                      result
                                                          as DeviceSupplierVo;
                                                  controller.form.value
                                                      .supplier = supplier.name;
                                                  controller.supplierController
                                                          .value.text =
                                                      controller
                                                          .form.value.supplier!;
                                                }
                                              });
                                            }
                                          })),
                                    ))
                                  ],
                                ),
                              ),
                              SizedBox(
                                height: 50,
                                child: Row(
                                  children: [
                                    SizedBox(
                                      width: 100,
                                      child: Row(
                                        children: [
                                          Container(
                                            width: 40,
                                          ),
                                          Expanded(
                                              child: Center(
                                            child: Text(
                                              '采购部门',
                                              style:
                                                  StylesUtils.customTextStyle(
                                                      color: ColorsUtils
                                                          .color3333),
                                            ),
                                          ))
                                        ],
                                      ),
                                    ),
                                    Expanded(
                                        child: Container(
                                      padding: const EdgeInsets.only(left: 10),
                                      alignment: Alignment.centerLeft,
                                      child: Obx(() => TextField(
                                          textDirection: TextDirection.ltr,
                                          readOnly: true,
                                          controller: controller
                                              .buyDeptController.value,
                                          cursorColor: ColorsUtils
                                              .parseColorFromHexString(
                                                  ColorsUtils.color1c24),
                                          style: StylesUtils.customTextStyle(
                                              fontSize: 16,
                                              color: ColorsUtils.color1c24),
                                          textAlign: TextAlign.left,
                                          textAlignVertical:
                                              TextAlignVertical.center,
                                          cursorWidth: 2,
                                          cursorRadius:
                                              const Radius.circular(2),
                                          decoration: InputDecoration(
                                              hintText: '请选择采购部门',
                                              hintStyle:
                                                  StylesUtils.customTextStyle(
                                                      color:
                                                          ColorsUtils.colorCccc,
                                                      fontSize: 15),
                                              isDense: true,
                                              isCollapsed: true,
                                              fillColor: Colors.white,
                                              border: InputBorder.none,
                                              suffixIcon: Icon(
                                                AntdIcons.right,
                                                color: ColorsUtils
                                                    .parseColorFromHexString(
                                                        ColorsUtils.color9999),
                                                size: 15,
                                              ),
                                              focusColor: ColorsUtils
                                                  .parseColorFromHexString(
                                                      ColorsUtils.color1c24),
                                              contentPadding:
                                                  const EdgeInsets.only(
                                                      top: 10, bottom: 10),
                                              focusedBorder: InputBorder.none),
                                          onTap: () {
                                            Future<dynamic>? future =
                                                Get.toNamed(Routes.deptSelect);
                                            if (future != null) {
                                              future.then((result) {
                                                if (result != null) {
                                                  controller
                                                          .form.value.buyDept =
                                                      result['dept']
                                                          as DepartmentModel;
                                                  controller.buyDeptController
                                                          .value.text =
                                                      controller.form.value
                                                          .buyDept!.name;
                                                }
                                              });
                                            }
                                          })),
                                    ))
                                  ],
                                ),
                              ),
                              SizedBox(
                                height: 50,
                                child: Row(
                                  children: [
                                    SizedBox(
                                      width: 100,
                                      child: Row(
                                        children: [
                                          Container(
                                            width: 40,
                                          ),
                                          Expanded(
                                              child: Center(
                                            child: Text(
                                              '采购人员',
                                              style:
                                                  StylesUtils.customTextStyle(
                                                      color: ColorsUtils
                                                          .color3333),
                                            ),
                                          ))
                                        ],
                                      ),
                                    ),
                                    Expanded(
                                        child: Container(
                                      padding: const EdgeInsets.only(left: 10),
                                      alignment: Alignment.centerLeft,
                                      child: Obx(() => TextField(
                                          textDirection: TextDirection.ltr,
                                          readOnly: true,
                                          controller: controller
                                              .buyUserController.value,
                                          cursorColor: ColorsUtils
                                              .parseColorFromHexString(
                                                  ColorsUtils.color1c24),
                                          style: StylesUtils.customTextStyle(
                                              fontSize: 16,
                                              color: ColorsUtils.color1c24),
                                          textAlign: TextAlign.left,
                                          textAlignVertical:
                                              TextAlignVertical.center,
                                          cursorWidth: 2,
                                          cursorRadius:
                                              const Radius.circular(2),
                                          decoration: InputDecoration(
                                              hintText: '请选择负责人',
                                              hintStyle:
                                                  StylesUtils.customTextStyle(
                                                      color:
                                                          ColorsUtils.colorCccc,
                                                      fontSize: 15),
                                              isDense: true,
                                              isCollapsed: true,
                                              fillColor: Colors.white,
                                              border: InputBorder.none,
                                              suffixIcon: Icon(
                                                AntdIcons.right,
                                                color: ColorsUtils
                                                    .parseColorFromHexString(
                                                        ColorsUtils.color9999),
                                                size: 15,
                                              ),
                                              focusColor: ColorsUtils
                                                  .parseColorFromHexString(
                                                      ColorsUtils.color1c24),
                                              contentPadding:
                                                  const EdgeInsets.only(
                                                      top: 10, bottom: 10),
                                              focusedBorder: InputBorder.none),
                                          onTap: () {
                                            Future<dynamic>? future =
                                                Get.toNamed(Routes.deptSelect);
                                            if (future != null) {
                                              future.then((result) {
                                                if (result) {
                                                  controller
                                                          .form.value.buyUser =
                                                      result['user']
                                                          as UserModel;
                                                  controller.buyUserController
                                                          .value.text =
                                                      controller.form.value
                                                          .buyUser!.name;
                                                }
                                              });
                                            }
                                          })),
                                    ))
                                  ],
                                ),
                              ),
                              SizedBox(
                                height: 50,
                                child: Row(
                                  children: [
                                    SizedBox(
                                      width: 100,
                                      child: Row(
                                        children: [
                                          Container(
                                            width: 40,
                                          ),
                                          Expanded(
                                              child: Center(
                                            child: Text(
                                              '采购日期',
                                              style:
                                                  StylesUtils.customTextStyle(
                                                      color: ColorsUtils
                                                          .color3333),
                                            ),
                                          ))
                                        ],
                                      ),
                                    ),
                                    Expanded(
                                        child: Container(
                                      padding: const EdgeInsets.only(left: 10),
                                      alignment: Alignment.centerLeft,
                                      child: Obx(() => TextField(
                                          textDirection: TextDirection.ltr,
                                          readOnly: true,
                                          controller: controller
                                              .buyDateController.value,
                                          cursorColor: ColorsUtils
                                              .parseColorFromHexString(
                                                  ColorsUtils.color1c24),
                                          style: StylesUtils.customTextStyle(
                                              fontSize: 16,
                                              color: ColorsUtils.color1c24),
                                          textAlign: TextAlign.left,
                                          textAlignVertical:
                                              TextAlignVertical.center,
                                          cursorWidth: 2,
                                          cursorRadius:
                                              const Radius.circular(2),
                                          decoration: InputDecoration(
                                              hintText: '请选择启用日期',
                                              hintStyle:
                                                  StylesUtils.customTextStyle(
                                                      color:
                                                          ColorsUtils.colorCccc,
                                                      fontSize: 15),
                                              isDense: true,
                                              isCollapsed: true,
                                              fillColor: Colors.white,
                                              border: InputBorder.none,
                                              suffixIcon: Icon(
                                                AntdIcons.right,
                                                color: ColorsUtils
                                                    .parseColorFromHexString(
                                                        ColorsUtils.color9999),
                                                size: 15,
                                              ),
                                              focusColor: ColorsUtils
                                                  .parseColorFromHexString(
                                                      ColorsUtils.color1c24),
                                              contentPadding:
                                                  const EdgeInsets.only(
                                                      top: 10, bottom: 10),
                                              focusedBorder: InputBorder.none),
                                          onTap: () async {
                                            List<DateTime?>? results =
                                                await showCalendarDatePicker2Dialog(
                                              context: context,
                                              config:
                                                  CalendarDatePicker2WithActionButtonsConfig(
                                                calendarType:
                                                    CalendarDatePicker2Type
                                                        .single,
                                                calendarViewMode:
                                                    DatePickerMode.day,
                                                weekdayLabels: [
                                                  '日',
                                                  '一',
                                                  '二',
                                                  '三',
                                                  '四',
                                                  '五',
                                                  '六',
                                                ],
                                              ),
                                              dialogSize: const Size(325, 400),
                                              borderRadius:
                                                  BorderRadius.circular(15),
                                            );
                                            if (results != null &&
                                                results.isNotEmpty) {
                                              DateTime? d = results[0];
                                              if (d != null) {
                                                String startDate =
                                                    DateTimeFormatter
                                                        .formatDate(
                                                            d, 'yyyy-MM-dd');
                                                controller.form.value.buyDate =
                                                    startDate;
                                                controller.buyDateController
                                                    .value.text = startDate;
                                              }
                                            }
                                          })),
                                    ))
                                  ],
                                ),
                              ),
                              SizedBox(
                                height: 50,
                                child: Row(
                                  children: [
                                    SizedBox(
                                      width: 100,
                                      child: Row(
                                        children: [
                                          Container(
                                            width: 40,
                                          ),
                                          Expanded(
                                              child: Center(
                                            child: Text(
                                              '出厂日期',
                                              style:
                                                  StylesUtils.customTextStyle(
                                                      color: ColorsUtils
                                                          .color3333),
                                            ),
                                          ))
                                        ],
                                      ),
                                    ),
                                    Expanded(
                                        child: Container(
                                      padding: const EdgeInsets.only(left: 10),
                                      alignment: Alignment.centerLeft,
                                      child: Obx(() => TextField(
                                          textDirection: TextDirection.ltr,
                                          readOnly: true,
                                          controller: controller
                                              .leaveFactoryDateController.value,
                                          cursorColor:
                                              ColorsUtils.parseColorFromHexString(
                                                  ColorsUtils.color1c24),
                                          style: StylesUtils.customTextStyle(
                                              fontSize: 16,
                                              color: ColorsUtils.color1c24),
                                          textAlign: TextAlign.left,
                                          textAlignVertical:
                                              TextAlignVertical.center,
                                          cursorWidth: 2,
                                          cursorRadius:
                                              const Radius.circular(2),
                                          decoration: InputDecoration(
                                              hintText: '请选择启用日期',
                                              hintStyle:
                                                  StylesUtils.customTextStyle(
                                                      color:
                                                          ColorsUtils.colorCccc,
                                                      fontSize: 15),
                                              isDense: true,
                                              isCollapsed: true,
                                              fillColor: Colors.white,
                                              border: InputBorder.none,
                                              suffixIcon: Icon(
                                                AntdIcons.right,
                                                color: ColorsUtils
                                                    .parseColorFromHexString(
                                                        ColorsUtils.color9999),
                                                size: 15,
                                              ),
                                              focusColor: ColorsUtils
                                                  .parseColorFromHexString(
                                                      ColorsUtils.color1c24),
                                              contentPadding: const EdgeInsets.only(
                                                  top: 10, bottom: 10),
                                              focusedBorder: InputBorder.none),
                                          onTap: () async {
                                            List<DateTime?>? results =
                                                await showCalendarDatePicker2Dialog(
                                              context: context,
                                              config:
                                                  CalendarDatePicker2WithActionButtonsConfig(
                                                calendarType:
                                                    CalendarDatePicker2Type
                                                        .single,
                                                calendarViewMode:
                                                    DatePickerMode.day,
                                                weekdayLabels: [
                                                  '日',
                                                  '一',
                                                  '二',
                                                  '三',
                                                  '四',
                                                  '五',
                                                  '六',
                                                ],
                                              ),
                                              dialogSize: const Size(325, 400),
                                              borderRadius:
                                                  BorderRadius.circular(15),
                                            );
                                            if (results != null &&
                                                results.isNotEmpty) {
                                              DateTime? d = results[0];
                                              if (d != null) {
                                                String startDate =
                                                    DateTimeFormatter
                                                        .formatDate(
                                                            d, 'yyyy-MM-dd');
                                                controller.form.value
                                                        .leaveFactoryDate =
                                                    startDate;
                                                controller
                                                    .leaveFactoryDateController
                                                    .value
                                                    .text = startDate;
                                              }
                                            }
                                          })),
                                    ))
                                  ],
                                ),
                              ),
                              SizedBox(
                                height: 50,
                                child: Row(
                                  children: [
                                    SizedBox(
                                        width: 100,
                                        child: Align(
                                          alignment: Alignment.centerRight,
                                          child: Text(
                                            '生产厂商',
                                            style: StylesUtils.customTextStyle(
                                                color: ColorsUtils.color3333),
                                          ),
                                        )),
                                    Expanded(
                                        child: Container(
                                      padding: const EdgeInsets.only(left: 10),
                                      alignment: Alignment.centerLeft,
                                      child: Obx(() => TextField(
                                            textDirection: TextDirection.ltr,
                                            keyboardType: TextInputType.text,
                                            controller: TextEditingController(
                                                text: controller
                                                    .form.value.mobile),
                                            cursorColor: ColorsUtils
                                                .parseColorFromHexString(
                                                    ColorsUtils.color1c24),
                                            style: StylesUtils.customTextStyle(
                                                fontSize: 16,
                                                color: ColorsUtils.color1c24),
                                            textAlign: TextAlign.left,
                                            textAlignVertical:
                                                TextAlignVertical.center,
                                            cursorWidth: 2,
                                            cursorRadius:
                                                const Radius.circular(2),
                                            decoration: InputDecoration(
                                                hintText: '请输入生产厂商',
                                                hintStyle:
                                                    StylesUtils.customTextStyle(
                                                        color: ColorsUtils
                                                            .colorCccc,
                                                        fontSize: 15),
                                                isDense: true,
                                                isCollapsed: true,
                                                fillColor: Colors.white,
                                                border: InputBorder.none,
                                                focusColor: ColorsUtils
                                                    .parseColorFromHexString(
                                                        ColorsUtils.color1c24),
                                                contentPadding:
                                                    const EdgeInsets.symmetric(
                                                        vertical: 20),
                                                focusedBorder:
                                                    InputBorder.none),
                                            onChanged: (String text) {
                                              controller.form.value
                                                  .manufacturer = text;
                                            },
                                          )),
                                    ))
                                  ],
                                ),
                              ),
                              SizedBox(
                                height: 50,
                                child: Row(
                                  children: [
                                    SizedBox(
                                        width: 100,
                                        child: Align(
                                          alignment: Alignment.centerRight,
                                          child: Text(
                                            '使用寿命',
                                            style: StylesUtils.customTextStyle(
                                                color: ColorsUtils.color3333),
                                          ),
                                        )),
                                    Expanded(
                                        child: Container(
                                      padding: const EdgeInsets.only(left: 10),
                                      alignment: Alignment.centerLeft,
                                      child: Obx(() => TextField(
                                            textDirection: TextDirection.ltr,
                                            keyboardType: TextInputType.text,
                                            controller: TextEditingController(
                                                text: controller
                                                    .form.value.mobile),
                                            cursorColor: ColorsUtils
                                                .parseColorFromHexString(
                                                    ColorsUtils.color1c24),
                                            style: StylesUtils.customTextStyle(
                                                fontSize: 16,
                                                color: ColorsUtils.color1c24),
                                            textAlign: TextAlign.left,
                                            textAlignVertical:
                                                TextAlignVertical.center,
                                            cursorWidth: 2,
                                            cursorRadius:
                                                const Radius.circular(2),
                                            decoration: InputDecoration(
                                                hintText: '请输入使用寿命',
                                                hintStyle:
                                                    StylesUtils.customTextStyle(
                                                        color: ColorsUtils
                                                            .colorCccc,
                                                        fontSize: 15),
                                                isDense: true,
                                                isCollapsed: true,
                                                fillColor: Colors.white,
                                                border: InputBorder.none,
                                                focusColor: ColorsUtils
                                                    .parseColorFromHexString(
                                                        ColorsUtils.color1c24),
                                                contentPadding:
                                                    const EdgeInsets.symmetric(
                                                        vertical: 20),
                                                focusedBorder:
                                                    InputBorder.none),
                                            onChanged: (String text) {
                                              controller.form.value.life = text;
                                            },
                                          )),
                                    ))
                                  ],
                                ),
                              ),
                              SizedBox(
                                height: 50,
                                child: Row(
                                  children: [
                                    SizedBox(
                                        width: 100,
                                        child: Align(
                                          alignment: Alignment.centerRight,
                                          child: Text(
                                            '购买价格',
                                            style: StylesUtils.customTextStyle(
                                                color: ColorsUtils.color3333),
                                          ),
                                        )),
                                    Expanded(
                                        child: Container(
                                      padding: const EdgeInsets.only(left: 10),
                                      alignment: Alignment.centerLeft,
                                      child: Obx(() => TextField(
                                            textDirection: TextDirection.ltr,
                                            keyboardType: TextInputType.number,
                                            controller: TextEditingController(
                                                text: controller
                                                    .form.value.mobile),
                                            cursorColor: ColorsUtils
                                                .parseColorFromHexString(
                                                    ColorsUtils.color1c24),
                                            style: StylesUtils.customTextStyle(
                                                fontSize: 16,
                                                color: ColorsUtils.color1c24),
                                            textAlign: TextAlign.left,
                                            textAlignVertical:
                                                TextAlignVertical.center,
                                            cursorWidth: 2,
                                            cursorRadius:
                                                const Radius.circular(2),
                                            decoration: InputDecoration(
                                                hintText: '请输入购买价格',
                                                hintStyle:
                                                    StylesUtils.customTextStyle(
                                                        color: ColorsUtils
                                                            .colorCccc,
                                                        fontSize: 15),
                                                isDense: true,
                                                isCollapsed: true,
                                                fillColor: Colors.white,
                                                border: InputBorder.none,
                                                focusColor: ColorsUtils
                                                    .parseColorFromHexString(
                                                        ColorsUtils.color1c24),
                                                contentPadding:
                                                    const EdgeInsets.symmetric(
                                                        vertical: 20),
                                                focusedBorder:
                                                    InputBorder.none),
                                            onChanged: (String text) {
                                              controller.form.value.price =
                                                  double.tryParse(text);
                                            },
                                          )),
                                    ))
                                  ],
                                ),
                              ),
                            ],
                          ),
                        ),
                        Container(
                          height: 40,
                          margin: const EdgeInsets.only(top: 15),
                          decoration: const BoxDecoration(color: Colors.white),
                          child: CustomPaint(
                              painter: _MyCustomPaintLine(),
                              child: Container(
                                  margin: const EdgeInsets.only(left: 30),
                                  alignment: Alignment.centerLeft,
                                  child: Row(
                                    mainAxisAlignment:
                                        MainAxisAlignment.spaceBetween,
                                    children: [
                                      Text(
                                        '设备图片',
                                        style: StylesUtils.customTextStyle(
                                            color: ColorsUtils.color6666),
                                      ),
                                      IconButton(
                                          padding: EdgeInsets.zero,
                                          alignment: Alignment.center,
                                          onPressed: () {
                                            ToolsUtils.openGalleryImage(
                                                (List<XFile> res) {
                                              controller.uploadFilePath(res);
                                            });
                                          },
                                          icon: ToolsUtils.assetImageSvg(
                                              'u6316.svg',
                                              width: 20,
                                              height: 20))
                                    ],
                                  ))),
                        ),
                        Container(
                          decoration: const BoxDecoration(color: Colors.white),
                          alignment: Alignment.centerLeft,
                          child: Wrap(
                            spacing: 10,
                            runSpacing: 10,
                            children: controller.imgs
                                .map((element) => Stack(
                                      children: [
                                        ImageOverlay(
                                            image:
                                                FileImage(File(element.path)),
                                            width: 80,
                                            height: 80),
                                        Positioned(
                                            top: 0,
                                            right: 0,
                                            width: 20,
                                            height: 20,
                                            child: IconButton(
                                                alignment: Alignment.center,
                                                padding: EdgeInsets.zero,
                                                onPressed: () {
                                                  controller.imgs
                                                      .remove(element);
                                                },
                                                icon: Icon(
                                                  AntdIcons.closeCircleFill,
                                                  color: ColorsUtils
                                                      .parseColorFromHexString(
                                                          ColorsUtils
                                                              .color3333),
                                                  size: 20,
                                                )))
                                      ],
                                    ))
                                .toList(),
                          ),
                        ),
                        Container(
                          height: 40,
                          margin: const EdgeInsets.only(top: 15),
                          decoration: const BoxDecoration(color: Colors.white),
                          child: CustomPaint(
                              painter: _MyCustomPaintLine(),
                              child: Container(
                                  margin: const EdgeInsets.only(left: 30),
                                  alignment: Alignment.centerLeft,
                                  child: Row(
                                    mainAxisAlignment:
                                        MainAxisAlignment.spaceBetween,
                                    children: [
                                      Text(
                                        '关联文档',
                                        style: StylesUtils.customTextStyle(
                                            color: ColorsUtils.color6666),
                                      ),
                                      IconButton(
                                          padding: EdgeInsets.zero,
                                          alignment: Alignment.center,
                                          onPressed: () async {
                                            List<PlatformFile>? files =
                                                await ToolsUtils.openPickerFile(
                                                    null);
                                            if (files != null &&
                                                files.isNotEmpty) {
                                              controller.files.addAll(files);
                                            }
                                          },
                                          icon: ToolsUtils.assetImageSvg(
                                              'u18142.svg',
                                              width: 20,
                                              height: 20))
                                    ],
                                  ))),
                        ),
                        Container(
                          decoration: const BoxDecoration(color: Colors.white),
                          child: ListBody(
                            children: controller.files
                                .map((element) => Row(
                                      mainAxisAlignment:
                                          MainAxisAlignment.spaceBetween,
                                      children: [
                                        Container(
                                            height: 40,
                                            alignment: Alignment.centerLeft,
                                            child: Wrap(
                                              spacing: 15,
                                              children: [
                                                Container(
                                                  width: 40,
                                                  alignment: Alignment.center,
                                                  child: Image(
                                                    width: 25,
                                                    height: 25,
                                                    image: ToolsUtils
                                                        .getFileIconByFilename(
                                                            element.name),
                                                  ),
                                                ),
                                                Align(
                                                  alignment:
                                                      Alignment.centerLeft,
                                                  child: Text(
                                                    element.name,
                                                    overflow:
                                                        TextOverflow.ellipsis,
                                                    style: StylesUtils
                                                        .customTextStyle(
                                                            color: ColorsUtils
                                                                .color0052),
                                                  ),
                                                )
                                              ],
                                            )),
                                        IconButton(
                                            alignment: Alignment.center,
                                            padding: EdgeInsets.zero,
                                            onPressed: () {
                                              controller.files.remove(element);
                                            },
                                            icon: Icon(
                                              AntdIcons.close,
                                              size: 15,
                                              color: ColorsUtils
                                                  .parseColorFromHexString(
                                                      ColorsUtils.color9999),
                                            ))
                                      ],
                                    ))
                                .toList(),
                          ),
                        )
                      ],
                    ))),
            extendBody: true,
            bottomSheet: Container(
              height: 70,
              decoration: BoxDecoration(
                  color: Colors.white,
                  border: Border(
                      top: BorderSide(
                          color: ColorsUtils.parseColorFromHexString(
                              ColorsUtils.colorE4e4)))),
              alignment: Alignment.center,
              child: FractionallySizedBox(
                widthFactor: 0.9,
                heightFactor: 0.75,
                alignment: Alignment.center,
                child: BrnNormalButton(
                  onTap: () {
                    Get.offNamedUntil(Routes.deviceInfo,
                        (route) => route.settings.name == Routes.deviceInfo);
                  },
                  backgroundColor: ColorsUtils.parseColorFromHexString(
                      ColorsUtils.color0052),
                  text: '',
                  child: Text(
                    '提交',
                    style: StylesUtils.customTextStyle(fontSize: 14),
                  ),
                ),
              ),
            ));
      },
      init: controller,
    );
  }
}

class _MyCustomPaintLine extends CustomPainter {
  @override
  void paint(Canvas canvas, Size size) {
    /// w = 10, h = 20
    Paint paint = Paint()
      ..isAntiAlias = false
      ..color = ColorsUtils.parseColorFromHexString(ColorsUtils.color0052)
      ..style = PaintingStyle.fill;
    Rect rect = const Rect.fromLTWH(10, 10, 10, 20);
    canvas.drawRect(rect, paint);
  }

  @override
  bool shouldRepaint(covariant CustomPainter oldDelegate) {
    return this != oldDelegate;
  }
}
